package com.ztf.shopping.web.servlet;

import com.ztf.shopping.service.UserService;
import com.ztf.shopping.service.imp.UserServiceImp;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Arrays;

/**
 * 提交订单
 */
@WebServlet("/payOrder")
public class PayOrder extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String list = request.getParameter("list"); //返回以#号为分割的字符串
        String[] split = list.split("#");
        UserService service = new UserServiceImp();
        Object loginUser = request.getSession().getAttribute("loginUser");
        service.payOrder(loginUser,split);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doPost(request, response);
    }
}
